{% extends "base.html" %}

{% block formJs %}
<script type="text/javascript" src="/js/form.js"></script>
{% endblock %}

{% block js %}

/**
 * load 時に表示する Map
 */
function loadMain() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("mainMap"));
        map.setCenter(new GLatLng({{ result.lon }}, {{ result.lat }}),
            13);
        //map.addControl(new GMapTypeControl());
        map.addControl(new GSmallMapControl());

        latlng = new GLatLng({{ result.lon }}, {{ result.lat }});
        
        var marker = new GMarker(latlng);
        map.addOverlay(marker);
    }
}

function checkDel(title, key) {
    var message = '「' + title + '」を削除しますか？';
    if(confirm(message)) {
        $.ajax({
            url : '/del/' + key,
            type : 'get',
            complete : function(){
                parent.parent.location.href = '{{ app.url }}';
            }
        });
    }
}

window.addEventListener('load', loadMain, false);

{% endblock %}

{% block body %}

<div id="content">
    
    <p>&nbsp;</p>
    
    <div id="editMap">
      <div id="mainMap" style="width: 400px; height: 300px">&nbsp;</div>
    </div>
  
    <div id="editContent" class="key">
        <div id="edit-container">
            <h2>{{ result.title }}</h2>
            <div id="basicContent">
                <span><a href="/send/{{ result.key }}" onclick="return GB_showCenter('{{ result.title }} の共有', this.href, 600, 620)"><img src="/img/mail.png" />共有</a></span>
                <span><a href="/edit/{{ result.key }}" onclick="return GB_showCenter('{{ result.title }} の編集', this.href, 640, 600)"><img src="/img/edit.png" />編集</a></span>
                <span><a href="javascript:checkDel('{{ result.title }}','{{ result.key }}');"><img src="/img/trash.png" />削除</a></span>
            </div>
            
            <table id="edit" class="contact-content">
                <tr>
                    <td class="label">URL:</td>
                    <td><input style="width:100%;" type="text" readonly value="{{ app.url }}key/{{ result.key }}" /></td>
                </tr>
                <tr>
                    <td class="label" for="published">公開する:</td>
                    <td>
                    {% if result.published %}
                        はい
		            {% else %}
                        いいえ
		            {% endif %}
		            </td>
    	        </tr>
                <tr>
                    <td class="label" for="lon">経度:</td>
                    <td>{{ result.lon }}</td>
                </tr>
                <tr>
                    <td class="label" for="lat">緯度:</td>
                    <td>{{ result.lat }}</td>
                </tr>
                <tr>
                    <td class="label" for="message">メモ:</td>
                    <td>{{ result.memo }}</td>
                </tr>
                <tr>
                    <td class="label" for="author">登録者:</td>
                    <td>{{ result.author }}</td>
                </tr>
                <tr>
                    <td class="label" for="createdDate">登録日:</td>
                    <td>{{ result.created|window_date }}</td>
                </tr>
            </table>
            <div style="clear:both;">&nbsp</div>
        </div>
    
    </div>
</div>

{% endblock %}
